package proxy.dbroute.db;

/**
 * @author zhangxi
 * @date 2021/2/25
 */
public class DynamicDataSourceEntity {

    private static final String DEFAULT_SOURCE = null;

    private static final ThreadLocal<String> threadLocal = new ThreadLocal<String>();

    private DynamicDataSourceEntity() {
    }

    public static String get() {
        return threadLocal.get();
    }

    public static void set(String source) {
        threadLocal.set(source);
    }

    public static void set(Integer year) {
        threadLocal.set("DB_" + year);
    }

    public static void restore() {
        threadLocal.set(DEFAULT_SOURCE);
    }

}
